
<template>
  <div>

    <el-card style="width: 40%;margin: 10px">
      <el-form
         ref="form" :model="form" label-width="80px"
      >
        <el-form-item label="用户名">
          <el-input v-model="form.username" />
        </el-form-item>
        <el-form-item label="用户年龄">
          <el-input v-model="form.age" />
        </el-form-item>
        <el-form-item label="用户性别">
          <el-input v-model="form.sex" />
        </el-form-item>
        <el-form-item label="用户地址">
          <el-input v-model="form.address" />
        </el-form-item>
        <el-form-item label="用户昵称">
          <el-input v-model="form.nickName" />
        </el-form-item>
        <el-form-item label="个人密码">
          <el-input v-model="form.password"  show-password/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="confirm" style="text-align: center"
          >保存</el-button>
        </el-form-item>
      </el-form>
    </el-card>

  </div>
</template>


<script>
import request from "@/utils/request";

export default {
  name: "Person",
  components: {},
  data(){
    return{
      form: {}
    }
  },
  methods: {
    confirm(){
      request.put("/user/person/update",this.form).then(res=>{
        if(res.code==='0'){
          this.$message({
            type: "success",
            message: "更新成功"
          })
          sessionStorage.setItem("user",JSON.stringify(this.form))
        }else{
          this.$message({
            type: "error",
            message: "更新失败"
          })
        }
      })
    }


  },

  /*
  created() {
    let str=sessionStorage.getItem("user");
    this.form=JSON.parse(str)
  }*/
}
</script>
<style scoped>

</style>
